{% set widgetname = 'news' %}
{% set categories = widgetDataByType(
'blogCategories', {
widget_name: 'news',
onlysite: false,
onlyglobal: true,
}
).categories %}
{% set pkid = xget('pkid') %}
{% set categories_g = [] %}
{% for cat in categories %}
{% set categories_g = xadd(categories_g, cat.pkid, cat.name[currentlang]) %}
{% endfor %}
{% if pkid is not null %}
{% set addViews = ioCallAction(
'io.model.cms20.content.blog.addViews', {
pkid: pkid,
widget_name: widgetname,
}
) %}
{% set data = widgetDataByType(
'blog', {
widget_name: widgetname,
start: 0,
limit: 1,
filter: {
public: 1,
lang: (site.languages[currentlang] is defined ? currentlang : site.langdefault),
pkid: pkid,
'<=ugmtimePublic': time(),
},
viewall: 1,
}
).res.0 %}
{{setTitlePre(data.head~' - '~page.name)}}
{% if data.image is not null and data.image != '' %}
{{setMetaImage('//'~site.domain~'/files/sites/'~data.site_owner~'/'~data.widget_name~'/'~data.image)}}
{% endif %}
{% if data.tag %}
{{setMetaKeywordsPre(data.tag)}}
{% endif %}
{{writeMetaArticle(widgetname, pkid, currentlang)}}
{% set dataimage = '/img/cms/no-img.jpg' %}
{% if data.image is not null and data.image != '' %}
{% set dataimage = '/files/sites/'~data.site_owner~'/'~data.widget_name~'/'~data.image %}
{% endif %}
{{data.head}}
{{data.description | youTubeVideo | purify | raw}}
{{data.gmtimePublic | iostrtodate('d.m', 'Asia/Almaty')}}
{{data.likes}}
{% if data.domain is not null %}
{% set href = link('http://'~data.domain~'/news/?pkid='~data.pkid) %}
{% endif %}
{{translate['eop.view_news_on_site']}}
{{translate['eop.all_news']}}
{{translate['eop.comment']}}
{% else %}
{% set filter = {public: 1, lang: (site.languages[currentlang] is defined ? currentlang : site.langdefault), '<=ugmtimePublic': time()} %}
{% if xget('category') is not null %}
{% set filter = xadd(filter, 'category', xget('category')) %}
{% endif %}
{% if xget('text') is not null %}
{% set filter = xadd(filter, 'text', xget('text')) %}
{% endif %}
{% if xget('city') is not null and neqi(xget('city'), '0') %}
{% set filter = xadd(filter, 'city', xget('city')) %}
{% elseif xget('region') is not null and neqi(xget('region'), '0') %}
{% set filter = xadd(filter, 'region', xget('region')) %}
{% elseif xget('country') is not null and neqi(xget('country'), '0') %}
{% set filter = xadd(filter, 'country', xget('country')) %}
{% endif %}
{% set onpage = 12 %}
{% set start = (xget('page', 1) - 1) * onpage %}
{% set r = widgetDataByType(
'blog', {
widget_name: widgetname,
start: start,
limit: onpage,
filter: filter,
order: {
gmtimeAdd: 'asc',
},
}
) %}
{{v2_dump(onpage)}}
{% set categories = widgetDataByType(
'blogCategories',
{
widget_name: 'news',
onlysite: false,
onlyglobal: false,
},
[
{
name: {
ru: 'a',
en: 'a',
kz: 'a',
},
pkid: 0,
},
{
name: {
ru: 'b',
en: 'b',
kz: 'b',
},
pkid: 0,
},
]
).categories %}
{% set categories_g = [] %}
{% for cat in categories %}
{% set categories_g = xadd(categories_g, cat.pkid, cat.name[currentlang]) %}
{% endfor %}
{% set list = r.res %}
{% set list_count = r.count %}
{% for item in list %}
{% set href = link('/news/?pkid='~item.pkid) %}
{% if item.domain is not null %}
{% set href = link('http://'~item.domain~'/news/?pkid='~item.pkid) %}
{% endif %}
{% set cat = item.category %}
{{categories_g[item.category]}}
{% endfor %}
{% set ppage = max(xget('page', 0), 1) %}
{% set alfa = 1 %}
{% set count = (list_count / onpage) | ceil %}
{% if count > 1 %}
{% endif %}
{% endif %}